class: center, middle, inverse, title-slide .title[ # ISA 444: Business Forecasting ] .subtitle[ ## 01: Introduction to Time Series Analysis and Forecasting ] .author[ ###
Fadel M. Megahed, PhD
Endres Associate Professor
Farmer School of Business
Miami University
@FadelMegahed
fmegahed
fmegahed@miamioh.edu
Automated Scheduler for Office Hours
] .date[ ### Spring 2023 ] --- # Learning Objectives for Today's Class - Describe **course motivation** and **structure**. - Explain the differences between **cross sectional**, **time series** and **panel** datasets. - Describe the **components of time series** datasets. - Explain the **forecasting steps**. --- class: inverse, center, middle # Course Motivation and Structure --- # The Analytics Journey: Pre-analytics **Pre-Analytics/Data Management:** where one attempts to **extract** the needed *data* for analysis. --
--- # The Analytics Journey: Descriptive
−
+
03
:
00
**Descriptive Analytics:** where one attempts to **understand** the data through **visualizations**, **descriptive statistics**, and **exploratory statistical models**. .panelset[ .panel[.panel-name[Activity] > Over the next 3 minutes, please identify what you have learned from the charts in each tab. - Write down your answers in the last tab (it is editable). - Discuss your answers with your neighboring classmates. - Be prepared to share these answers with class. ] .panel[.panel-name[Viz 1] <img src="data:image/png;base64,#01_intro_files/figure-html/clothing_sales_viz1-1.png" style="display: block; margin: auto;" /> ] .panel[.panel-name[Viz 2]
] .panel[.panel-name[Viz 3]
] .panel[.panel-name[Viz 4]
] .panel[.panel-name[Key Points] .can-edit.key-activity1_viz[ **Main Insight(s):** .font70[(Insert below)] - Edit me - ... - ... ] ] ] --- count: false # The Analytics Journey: Descriptive **Descriptive Analytics:** where one attempts to **understand** the data through **visualizations**, **descriptive statistics**, and **exploratory statistical models**.
--- # The Analytics Journey: Predictive **Predictive Analytics:** where **statistical** and **machine learning** models are used to help us utilize independent variable[s] to predict an outcome variable of choice.
--- # The Analytics Journey: Prescriptive **Prescriptive Analytics:** where **mathematical models** are used to make recommendations for business actions. - Our **overarching goal** behind data/business analytics, is to **make informed decisions based on what we have learned from the data**. Hence, this stage is where we build on what we learned during the *descriptive* and *predictive* stages to make more informed decisions. - Imagine that you are L Brands or Express Inc.; how would you use the information pertaining to the **U.S. trends in clothing sales for staffing and operational decisions**? --- # How does our Curriculum at Miami University Prepare you for this Journey? <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/ba_flow_chart.png" alt="Fadel's take on our ISA curriculum" width="100%" /> <p class="caption">My take on the courses within the business analytics major/minor at Miami University</p> </div> --- # Why are time series data different? .pull-left[ - Time series (TS) data **cannot be** analyzed using standard regression techniques. - In regression, you assume that your data are **randomly sampled, resulting in independent observations.** - In TS, we want to capitalize on the **structure of the data**, i.e., observations are typically **correlated over time (autocorrelated)** to build our models. ] .pull-right[
] --- # Course Objectives By the **end of this course**, you should be able to: - Explain the purpose of forecasting in a business setting. - Use the basic tools of forecasting including plots, summary measures, transformations, measures of forecast accuracy, and prediction intervals. - Use an appropriate smoothing-based method for time series analysis and forecasting. - Use an appropriate ARIMA model to forecast a time series. - Use simple and multiple linear regression models to forecast a time series. --- # Why Should You Care? - **Sales forecasting:** Businesses use time series analysis to forecast future sales based on historical sales data, in order to make informed decisions about inventory management, staffing, and marketing efforts. - **Financial forecasting:** Companies use time series analysis to forecast future financial performance, such as revenue, expenses, and profits, in order to make strategic business decisions and plan for future growth. - **Demand forecasting:** Manufacturers and retailers use time series analysis to forecast demand for their products, in order to optimize production and inventory levels. - **Resource planning:** Businesses use time series analysis to forecast resource usage, such as energy consumption, in order to plan for future infrastructure needs and reduce costs. --- count: false # Why Should You Care? <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/indeed_forecasting.png" alt="118 Active Entry-Levl Forecasting Jobs that Require the R Programming Language and offers a salary larger than 85000 dollars" width="100%" height="500px" /> <p class="caption">118 Open Entry-Level Jobs that You Should be Applying to Right Now</p> </div> --- # Instructional Approach <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/instructional_approach.png" alt="An overview of the instructional approach for ISA 444." width="100%" /> <p class="caption">An overview of the instructional approach for ISA 444.</p> </div> --- # How will I Evaluate your Learning? <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/evaluation.png" alt="An overview of the evaluation components for ISA 444." width="100%" /> <p class="caption">An overview of the evaluation components for ISA 444.</p> </div> --- class: inverse, center, middle # Types of Data Over Time --- # Cross Sectional Data **Cross Sectional Data:** Measurements on multiple units, recorded in a single time period. **Example 1:** H1B 2020-2022 Data for Senior Data Scientists at Netflix
.footnote[ <html> <hr> </html> Data scraped from <https://h1bdata.info/index.php?em=Netflix+Inc&job=Senior+Data+Scientist&city=LOS+GATOS&year=All+Years> on January 23, 2023 using the [rvest](https://cran.r-project.org/web/packages/rvest/rvest.pdf)
. The printing was limited to those individuals who started on/after January 01, 2020, with the filters specified in the URL. ] --- count:: false # Cross Sectional Data **Cross Sectional Data:** Measurements on multiple units, recorded in a single time period. **Example 2:** NBA 2022-2023 Leaders - Top Players in PTS/Game
.footnote[ <html> <hr> </html> **Source:** Data scraped from <https://www.basketball-reference.com/leagues/NBA_2023_per_game.html}{Basketball-Reference> on January 23, 2023 using the [rvest](https://cran.r-project.org/web/packages/rvest/rvest.pdf)
. The printing was limited to the selected variables. ] --- # Time Series Data **Time Series Data:** Comparable measurements recorded on a single (or a few) variables over time (usually a long period of time). **Example:** Stock prices of U.S. Airlines
--- # Panel Data **Panel Data:** Cross sectional measurements (usually many variables) repeated over time (usually over a few time periods). **Example:** World Bank's Data
.footnote[ <html> <hr> </html> **Source:** Data queried from the [World Bank Data](https://datacatalog.worldbank.org/) using the [wbstats](https://cran.r-project.org/web/packages/wbstats/wbstats.pdf)
in R. The printed results show a snapshot of 7 variables (out of a much larger panel dataset). You can think of panel data as a cross-sectional dataset with a longitudinal/time component. ] --- class: inverse, center, middle # Components of a Time Series --- # Trend A **trend** is an increasing or decreasing pattern over time.
--- count:false # Trend A **trend** is an increasing or decreasing pattern over time.
--- # Seasonality **Seasonality** refers to the property of a time series that displays REGULAR patterns that repeat at a constant frequency (*m*).
--- # Cycle **Cyclical fluctuations** are somewhat irregular (unknown duration).
--- # Kahoot Competition #01 To assess your understanding and retention of the topics covered so far, you will **compete in a Kahoot competition (consisting of 5 questions)**: - Go to <https://kahoot.it/> - Enter the game pin, which will be shown during class - Provide your first (preferred) and last name - Answer each question within the allocated 20-second window (**fast and correct answers provide more points**) <br> **Winning the competition involves having as many correct answers as possible AND taking the shortest duration to answer these questions.** The winner
of the competition will receive a gift of their choosing ($10 Starbucks gift card or a large chocolate bar). Good luck!!! .footnote[ <html> <hr> </html> **P.S:** The Kahoot competition will have **no impact on your grade**. It is a **fun** way of assessing your knowledge, motivating you to ask questions about topics covered that you do not have a full understanding of it, and providing me with some data that I can use to pace today's class. ] --- class: inverse, center, middle # Forecasting and Steps --- # So What is Forecasting? <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/forecast_def.png" alt="The definition of the term forecast as obtained from Bing." width="60%" /> <p class="caption">Forecasting as defined by the Oxford Dictionary.</p> </div> --- # Working Definitions .content-box-grey[ **Forecasting:** .black[.bold[The process of predicting a future event. The objective of most time series analyses is to provide forecasts of future values of the time series.]] ] .content-box-grey[ **Time Series:** .black[.bold[A time series is a sequence of observations on a variable measured at successive points in time or over successive periods of time. In the simplest cases, observations are evenly spaced at regular intervals such as hourly, daily, weekly, monthly, or yearly, or at any other regular interval]] ] .footnote[ <html> <hr> </html> Source: Both definitions are based on [Dr. Allison Jones-Farmer’s](https://miamioh.edu/fsb/directory/?up=/directory/farmerl2) lecture notes, Miami University, Spring 2020. ] --- # Why do we Forecast? (PIVASE) - **Purpose:** What do we hope to achieve by generating the forecast? That is, what plans are dependent upon the results of the forecasting exercise? How far ahead do we wish to forecast? We refer to this period as the forecasting horizon. - **Information:** What do we know that may help us in forecasting. And when will we know it? Detailed data is only useful if it is available in timely fashion. - **Value:** How valuable is the forecast? What would you pay for perfect knowledge? - **Analysis:** From analyzing the data can we develop a model that captures its characteristics? And how does it perform on new (hold-out sample) data? - **System:** What models and software are needed to meet the needs of the organization? - **Evaluation:** How do we know whether a particular forecasting exercise was effective and what the potential is for improvement? .footnote[ <html> <hr> </html> From: Ord, K., Fildes, R., & Kourentzes, N. (2017). Principles of Business Forecasting (2nd ed., p. 3-6). ] --- # Why do Businessess Forecast? <div class="figure" style="text-align: center"> <img src="data:image/png;base64,#../../figures/why_business_forecast.png" alt="An Organization’s Forecasting Needs" width="65%" /> <p class="caption">An Organization’s Forecasting Needs</p> </div> .footnote[ <html> <hr> </html> From: Ord, K., Fildes, R., & Kourentzes, N. (2017). Principles of Business Forecasting (2nd ed., p. 7). ] --- # Forecasting Step by Step On the basis of our preliminary discussion of **PIVASE**, we can identify **seven major steps in the forecasting process:** 1. Define the forecasting and planning problem, the forecast horizon and decide the value of better forecasts. 1. Determine the resources to be devoted to providing the forecasts. 1. Collect relevant information, whether from a survey, from company records, or from information generated by other agencies (e.g., government figures). 1. Conduct an initial analysis of the data. 1. Select an appropriate forecasting method. 1. Generate forecasts. 1. Evaluate the forecasting exercise by checking forecasts against actual outcomes. .footnote[ <html> <hr> </html> From: Ord, K., Fildes, R., & Kourentzes, N. (2017). Principles of Business Forecasting (2nd ed., p. 16). ] --- class: inverse, center, middle # Recap --- # Summary of Main Points By now, you should be able to do the following: - Describe **course motivation** and **structure**. - Explain the differences between **cross sectional**, **time series** and **panel** datasets. - Describe the **components of time series** datasets. - Explain the **forecasting steps**. --- # Things to Do to Prepare for Our Next Class - Go over your notes and complete [Assignment 01](https://miamioh.instructure.com/courses/188655/quizzes/531534/) on Canvas. - Read through [Chapter 01 of our reference book](https://cdn.shopify.com/s/files/1/0859/4364/files/Part_I_POBF-_A_First_Course_in_Forecasting_1.pdf?612) and skim the following: .pull-left[ .center[[<img src="https://d33wubrfki0l68.cloudfront.net/b88ef926a004b0fce72b2526b0b5c4413666a4cb/24a30/cover.png" height="250px">](https://r4ds.had.co.nz)] .small[ * [Workflow: basics](https://r4ds.had.co.nz/workflow-basics.html) * [Workflow: scripts](https://r4ds.had.co.nz/workflow-scripts.html) * [Workflow: project](https://r4ds.had.co.nz/workflow-projects.html) ] ] .pull-right[ .center[[<img src="https://d33wubrfki0l68.cloudfront.net/565916198b0be51bf88b36f94b80c7ea67cafe7c/7f70b/cover.png" height="250px">](https://adv-r.hadley.nz)] .small[ * [Names and values](https://adv-r.hadley.nz/names-values.html) * [Vectors](https://adv-r.hadley.nz/vectors-chap.html) * [Subsetting](https://adv-r.hadley.nz/subsetting.html) ] ]